﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Enterprise.Data.Common
{
    /// <summary>
    /// 供所有Service调用的公共方法
    /// 这是一个多余的封装,仅为了保持三层结构，方便当某个Service没有Data时使用 
    /// 主要因为Service无法调用DataFactroy
    /// </summary>
    public class Data
    {
        /// <summary>
        /// 执行
        /// </summary>
        /// <param name="sql"></param>
        public void ExcuteSql(string sql)
        {
            DataFactory.DbExecute.Execute(sql);
        }
        /// <summary>
        /// 是否存在:select count(1) from xxxx
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        public bool Exist(string sql)
        {
            return DataFactory.DbExecute.Exist(sql);
        }

        /// <summary>
        /// 返回数据集
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public System.Data.DataSet GetDataSet(string sql)
        {
            return DataFactory.DbExecute.GetDataSet(sql);
        }

        /// <summary>
        /// 返回一个字段的值
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public object GetOjbect(string sql)
        {
            return DataFactory.DbExecute.ExecuteScalar(sql);
        }
    }
}
